package system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import common.controller.base.BaseController;
import common.model.po.MySqlSlowLog;
import common.model.request.base.PaginationRequest;
import common.model.response.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import system.model.request.SearchSlowLogRequest;
import system.service.MysqlSlowSqlService;

import javax.annotation.Resource;

/**
 * 慢查询日志
 *
 * @author 米泽鹏
 * @since 2022-3-23 下午 6:47
 */
@Api(tags = "慢查询日志")
@RestController
@RequestMapping("/system/slow-sql")
public class MysqlSlowSqlController extends BaseController {

	@Resource
	private MysqlSlowSqlService mysqlSlowSqlService;

	@ApiOperation(value = "慢查询日志分页查询", notes = "慢查询日志分页查询")
	@PostMapping("/readOnly/getAllSlowSql")
	public Result<Page<MySqlSlowLog>> getAllSlowLog(@ApiParam(value = "分页查询请求", required = true) @RequestBody @Validated PaginationRequest<SearchSlowLogRequest, MySqlSlowLog> paginationRequest) {
		return successWithData(mysqlSlowSqlService.pageSlowLog(paginationRequest));
	}

}
